﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

/// <summary>
/// Summary description for GlobalTransfer
/// </summary>
public class GlobalTransfer
{
    private GlobalTransfer()
    {
    }

    public static void RedirectToErrorPage(string errorMsg)
    {
        RedirectInfo info = new RedirectInfo();
        info.CustomMessage = errorMsg;
        RedirectToErrorPage(info);
    }

    /// <summary>
    /// 
    /// </summary>
    /// <param name="redirectInfo"></param>
    public static void RedirectToErrorPage(RedirectInfo redirectInfo)
    {
        StringBuilder sbUrl = new StringBuilder();
        sbUrl.Append(Globals.HttpRoot + "Error.aspx");
        if (redirectInfo != null)
        {
            if (!string.IsNullOrEmpty(redirectInfo.CustomMessage))
            {
                sbUrl.Append("?msg=");
                sbUrl.Append(redirectInfo.CustomMessage);
            }
        }

        HttpContext.Current.Response.Redirect(sbUrl.ToString());
    }
}


public class RedirectInfo
{
    public RedirectInfo()
    {
    }

    public RedirectInfo(string customerMsg)
    {
        customMessage = customerMsg;
    }

    private string customMessage;
    public string CustomMessage
    {
        get { return customMessage; }
        set { customMessage = value; }
    }
}
